<!DOCTYPE html>
<html style="background-color: #F1F4FB">

<head>
	<meta charset="utf-8">
	<title>论文台账页面</title>
	<!--公用样式-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/supplier/common/css/style.css"/>
	<!--extended-->
	<link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
	<!--Layui-->
	<link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
	<!--公用样式JS-->
	<script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
	<script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<style>
	.Right {
		overflow-y: auto;
		width: 100%;
		left: 16%;
		top: 144px;
	}
	.layui-table-cell {
		text-align: center;
		font-size:14px;
		padding:0 5px;
		height:auto;
		overflow:visible;
		text-overflow:inherit;
		white-space:normal;
		word-break: break-all;
	}
	.layui-laypage-limits select {
		width: 70px;
	}
</style>

<body>
<!--头部-->

<!--容器-->
<div class="layui-container" style="background-color: #ffffff;width:96%;margin-top:60px;padding:16px;border-radius: 10px">
	<!--筛选行-->
	<div style="background-color: #F1F4FB;border-radius: 5px;padding:14px 10px;">
		<div class="layui-row">
			<!--论文名称-->
			<div class="layui-col-md2" style="padding-left:1%">
				<span>论文名称:</span>
				<input id="lw_name" class="layui-input layui-input-inline" type="text" placeholder="论文名称" style="width: 50%">
			</div>
			<!--期刊类型-->
			<div class="layui-col-md2">
				<span>期刊类型:</span>
				<select id="qk_type_select">
					<option value="000">全部</option>
					<#list qklxList as qklx>
						<option value="${qklx.badtCode}">${qklx.badtName}</option>
					</#list>
				</select>
			</div>
			<!--期刊名称-->
			<div class="layui-col-md2" style="padding-left:1%">
				<span>期刊名称:</span>
				<input id="qk_name" class="layui-input layui-input-inline" type="text" placeholder="期刊名称" style="width: 50%">
			</div>
			<!--见刊日期-->
			<div class="layui-col-md4" style="padding-left:2%">
				<span>见刊日期:</span>
				<input id="jk_date_start" class="layui-input layui-input-inline" type="text" style="width: 32%;" placeholder="开始年份">
				<span>至</span>
				<input id="jk_date_end" class="layui-input layui-input-inline" type="text"  style="width: 32%;" placeholder="结束年份">
			</div>
			<!--期刊名称-->
			<div class="layui-col-md2" style="padding-left:1%">
				<input class="layui-btn layui-btn-normal fr" type="button"  value="筛选" onclick="query()">
			</div>
		</div>
<#--		<div class="layui-row" style="margin-top:8px">-->
<#--				<div class="layui-col-md3 layui-col-md-offset9">-->
<#--&lt;#&ndash;				<input class="layui-btn layui-btn-danger layui-btn-sm fr ml10" type="button" value="重置" onclick="resetQuery()">&ndash;&gt;-->
<#--				<input class="layui-btn layui-btn-normal layui-btn-sm fr" type="button"  value="筛选" onclick="query()">-->
<#--			</div>-->
<#--		</div>-->
	</div>
	<div style="height:40px"></div>
	<div class="layui-row">
		<div class="layui-col-md3 layui-col-md-offset9">
			<input class="layui-btn layui-btn-normal layui-btn-sm fr ml10" type="button" value="导出Excel" onclick="exportTable()">
			<input class="layui-btn layui-btn-danger layui-btn-sm fr" type="button" value="预览Excel" onclick="viewTable()">
		</div>
	</div>
	<div class="layui-row">
		<table id="booktable" layui-filter="booktable">

		</table>
	</div>

<#--	<div class="Right fr mt10">-->
<#--		<div class="layui-row" style="background-color: #e0e0e0;padding:20px 1%;margin-top:30px;border-radius: 5px">-->
<#--			<div class="layui-col-md2">-->
<#--				<span>计划类别:</span>-->

<#--			</div>-->
<#--			<div class="layui-col-md2" style="width: 26%">-->
<#--				<span style="display: inline-block;width:27%">获取时间:</span>-->
<#--				<input id="hp_time_begin" type="text"  style="display: inline-block;width:35%" value="2021-05-01">-->
<#--				<span>至</span>-->
<#--				<input id="hp_time_end" type="text"  style="display: inline-block;width:35%"  value="2021-05-02">-->
<#--			</div>-->
<#--		</div>-->
<#--	</div>-->
</div>
<div style="height: 50px"></div>
<#--	<!--右侧内容&ndash;&gt;-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/tabs.js"></script>
<script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
<#--<script type="text/html" id="xmjb">-->
<#--	{{# if(d.flag){ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="update"><i class="layui-icon">&#xe640;</i>编辑</a>-->
<#--	{{# }else{ }}-->
<#--	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="handle"><i class="layui-icon">&#xe640;</i>办理</a>-->
<#--	{{# } }}-->
<#--</script>-->
<script type="text/javascript">
	var table,tableIns,laydate,form,layer;
	layui.use(['laydate','table','form','layer'], function () {
		laydate = layui.laydate;
		table = layui.table;
		form = layui.form;
		layer = layui.layer;
		//执行一个laydate实例
		laydate.render({
			elem: '#jk_date_start', //见刊时间开思
			type: 'year'
		});
		laydate.render({
			elem: '#jk_date_end', //见刊时间结束
			type: 'year'
		});

		initTable();

	});

	function initTable(){
		//获取最多的作者个数:
		var jsonData = getQuaryData();
		$.ajax({
			url: '/search/decision/getAuthorCount',
			data: jsonData,
			type: 'get',
			dataType: 'json',
			success: function(res){
				console.log(res);
				if(res.flag){
					var indexList = res.data;
					//动态生成cols:
					var cols = [];
					var col = [];
					//序号:
					var ind = {
						title: '序号', width: '8%', templet: function (res) {
							return res.LAY_INDEX;
						}
					};
					col[col.length] = ind;
					//论文名称:
					var lwmc = {field: 'spfF1', title: '论文名称', width: '10%'};
					col[col.length] = lwmc;
					//遍历作者最大数:
					if(indexList && indexList.length>0){
						for(var i=0;i<indexList.length;i++){
							var indNo = ((indexList[i])*1)+1;
							var aAuthorField = {field: indexList[i], title: '第'+indNo+'作者', width: '10%'};
							col[col.length] = aAuthorField;
						}
					}
					//期刊类型:
					var qklx = {field: 'spfF3', title: '期刊类型', width: '10%',templet: function (d) {
							return '<span>'+getQklx(d.spfF3)+'</span>';
						}};
					col[col.length] = qklx;
					//期刊名称:
					var qkmc = {field: 'spfF4', title: '期刊名称', width: '10%'};
					col[col.length] = qkmc;
					//期刊分类
					var qkfl = {field: 'spfF6', title: '期刊分类', width: '10%',templet: function (d) {
							return '<span>'+getQkfl(d.spfF6)+'</span>';
						}};
					col[col.length] = qkfl;
					//见刊日期:
					var jkrq = {field: 'spfF2', title: '见刊日期', width: '15%'};
					col[col.length] = jkrq;
					//卷期:
					var jq = {field: 'spfF8', title: '卷期', width: '15%',templet: function (d) {
							return '<span>'+d.spfF8+'</span><span></span> - <span>'+d.spfF9+'</span>';
						}};
					col[col.length] = jq;
					//挂项目名称:
					var gxmmc = {field: 'spfF5', title: '挂项目名称', width: '15%'};
					col[col.length] = gxmmc;
					var lytzs = {field: 'fileList1', title: '录用通知书', width: '15%',templet: function(d){
							var returnStr = '';
							if(d.fileList1 && d.fileList1.length > 0){
								for(var a=0;a<d.fileList1.length;a++){
									returnStr = returnStr + '<p>'+d.fileList1[a].fileName+'</p>';
								}
								return returnStr;
							}else{
								return '';
							}
						}};
					col[col.length] = lytzs;
					var lwyg = {field: 'fileList2', title: '论文原稿', width: '15%',templet: function(d){
							var returnStr = '';
							if(d.fileList2 && d.fileList2.length > 0){
								for(var a=0;a<d.fileList2.length;a++){
									returnStr = returnStr + '<p>'+d.fileList2[a].fileName+'</p>';
								}
								return returnStr;
							}else{
								return '';
							}
						}};
					col[col.length] = lwyg;
					var qksmj = {field: 'fileList3', title: '期刊扫描件', width: '15%',templet: function(d){
							var returnStr = '';
							if(d.fileList3 && d.fileList3.length > 0){
								for(var a=0;a<d.fileList3.length;a++){
									returnStr = returnStr + '<p>'+d.fileList3[a].fileName+'</p>';
								}
								return returnStr;
							}else{
								return '';
							}
						}};
					col[col.length] = qksmj;
					cols[cols.length] = col;
					//方法级渲染
					tableIns = table.render({
						id: 'booktable',
						elem: '#booktable',
						url: '/search/decision/form/book/110005',
						height: "full",
						where: jsonData,
						page: true,
						cols: cols,
						done: function (res, currentCount) {

						}
					});
				}
			}
		})
	}

	function getQuaryData(){
		//论文名称
		var lwmcSelect = $('#lw_name').val();

		//期刊类型:
		var qklxSelect = $('#qk_type_select').val();

		//期刊名称
		var qkNameSelect = $('#qk_name').val();

		//见刊日期开始日期
		var jk_startSelect= $('#jk_date_start').val();

		//见刊日期结束日期
		var jk_endSelect= $('#jk_date_end').val();

		var jsondata = {
			spfF1:lwmcSelect,
			spfF3:qklxSelect,
			spfF4:qkNameSelect,
			spfF8:jk_startSelect,
			spfF9: jk_endSelect
		};
		return jsondata;
	}



	function query() {
		initTable();
	}

	function resetQuery(){
		$('#lw_name').val('');
		$('#qk_type_select').val('000');
		$('#qk_name').val('');
		$('#jk_date_start').val('');
		$('#jk_date_end').val('000');
		query();
	}

	function getQklx(qklx){
		var qklxListStr = '${qklxListStr}';
		var qklxList = JSON.parse(qklxListStr);
		var returnStr = '';
		if(qklxList && qklxList.length>0){
			for(var a=0;a<qklxList.length;a++){
				if(qklx == qklxList[a].badtCode){
					returnStr = qklxList[a].badtName;
				}
			}
		}
		return returnStr;
	}

	function getQkfl(qkfl){
		var qkflListStr = '${qkflListStr}';
		var qkflList = JSON.parse(qkflListStr);
		var returnStr = '';
		if(qkflList && qkflList.length>0){
			for(var a=0;a<qkflList.length;a++){
				if(qkfl == qkflList[a].badtCode){
					returnStr = qkflList[a].badtName;
				}
			}
		}
		return returnStr;
	}

	function viewTable(){
		var jsondata = getQuaryData();
		$.ajax({
			url: '/search/decision/form/book/viewTable/110005',
			data: jsondata,
			type: 'get',
			dataType: 'json',
			success: function(res){
				if(res.flag){
					if(res.data){
						var w = ($(window).width()*0.8);
						var h = ($(window).height()*0.8);
						POBrowser.openWindowModeless('/sys/office/openwordTemp?ft=1&fid=' + res.data, 'width=1200px;height=800px;', '{}')
					}
				}
			}
		})
	}

	function exportTable(){
		var jhlb = $('#play_type_select').val();
		var hpshStart = $('#hp_date_start').val();
		var hpshEnd = $('#hp_date_end').val();
		var projectName = $('#project_name').val();
		var xmjb = $('#project_level_select').val();
		var xmfzr = $('#project_fzr').val();
		var xdunit = $('#project_allow_unit').val();
		var para = '';
		if(jhlb){
			para = para+'&spfF3='+jhlb;
		}
		if(hpshStart){
			para = para+'&spfF9='+hpshStart;
		}
		if(hpshEnd){
			para = para+'&spfF10='+hpshEnd;
		}
		if(projectName){
			para = para+'&spfF1='+projectName;
		}
		if(xmjb){
			para = para+'&spfF2='+xmjb;
		}
		if(xmfzr){
			para = para+'&spfF12='+xmfzr;
		}
		if(xdunit){
			para = para+'&spfF7='+xdunit;
		}
		//获取全部数据:
		var url= '/search/decision/form/export/book/110005?a_='+Math.random()+para;
		location.href = url;
	}



</script>
</body>

</html>